﻿@model Product

@{
    List<Category> treeCategory = ViewBag.TreeCategory;
    List<PropertyType> propertyTypes = ViewBag.PropertyTypes;
    List<Style> styles = ViewBag.Styles;
    int? colorId = ViewBag.ColorId;

    Category cateLv2 = treeCategory.First(x => x.Level == 2);

    ViewBag.MenuOneId = cateLv2.ParentId;
    ViewBag.Title = String.Format("{0} {1} - {2}", Model.Category.Name, Model.Name, Model.Code);
}

<div id="product" class="details">
    <div class="container">
        <div class="bg-content no-padding">
            <div class="row">
                <div class="col-md-4">
                    <div>
                        <ol class="breadcrumb">
                            @for (int i = treeCategory.Count - 1; i >= 0; i--)
                            {
                                <li>
                                    <a href="#">
                                        @treeCategory[i].DisplayName
                                    </a>
                                </li>
                            }
                        </ol>
                        <div class="name">
                            @Model.Name
                        </div>
                        <div class="code">
                            @Model.Code
                        </div>
                        <div class="views">
                            <span class="label label-primary">
                                @Model.Views lượt xem
                            </span>
                        </div>
                        <hr />
                        <div class="thumbImage">
                            @Html.Action("_ThumbImage", new { product = Model, colorId = colorId })
                        </div>
                        <hr />
                        <div class="summary">
                            @Html.Raw(Model.Summary)
                        </div>
                        @if (!String.IsNullOrWhiteSpace(Model.Description))
                        {

                            @Html.Partial("_Description", Model)

                        }
                    </div>
                </div>
                <div class="col-md-5">
                    <div class="zoom">
                        <img id="mainImage" class="img-responsive center-block" src="" style="display: none;">
                    </div>
                    <video id="mainVideo" class="img-responsive" src="" style="display: none;"></video>
                </div>
                <div class="col-md-3">
                    <div>
                        <hr class="visible-sm visible-xs" />
                        @if (!String.IsNullOrWhiteSpace(Model.Category.SizeChart))
                        {
                            @Html.Partial("_SizeChart", Model)
                        }

                        @using (Html.BeginForm(null, null, FormMethod.Get, new { id = "frmAddToCart" }))
                        {
                            @Html.Action("_ColorPicker", new
                            {
                                product = Model,
                                categoryNameId = treeCategory.First(x => x.Level == 2).NameId,
                                colorId = colorId
                            })

                            foreach (PropertyType propType in propertyTypes)
                            {
                                string nameId = propType.Name.Replace(" ", "");

                                string propertyNameId = Request[nameId];

                                @Html.Action("_PropertyPicker", new { styles = ViewData[nameId], propertyType = propType, propertyNameId = propertyNameId })
                            }

                            @Html.Action("_PriceByStyle", new { styles = styles, listPrice = Model.ListPrice })
                        }

                        @Html.Partial("_ContactAboutShared")
                        <br />
                        @if (User.IsInRole("Admin") || User.IsInRole("Product Source"))
                        {
                            <a href="@Model.SourceLink" target="_blank" class="btn btn-primary">Nguồn</a>
                        }
                        @if (User.IsInRole("Admin") || User.IsInRole("Product Edit Public")
                            || (User.IsInRole("Product Edit Private") && Model.CreatedBy == User.Identity.Name))
                        {
                            <a href="@Url.Action("Index", "Product", new { area = "Admin" , search = Model.Code })" target="_blank" class="btn btn-primary">Chỉnh sửa</a>
                        }
                    </div>
                </div>
            </div>
        </div>
        @Html.Action("_Carousel", new { type = "same", product = Model, categoryNameId = cateLv2.NameId })
        <br />
        @Html.Action("_Carousel", new { type = "viewed", product = Model, categoryNameId = cateLv2.NameId })
    </div>
</div>


@section scripts {
    @Scripts.Render("~/Scripts/jquery.zoom.js")
    <script>
        $('.summary .table p').addClass('no-margin');
        $('.description .table p').addClass('no-margin');

        $('#menuOne-@cateLv2.Parent.NameId').addClass('active');
        $('#menuTwo-@cateLv2.NameId').addClass('active');
        $('#menuTwoXs-@cateLv2.NameId').addClass('active');

        new Product().DetailsLoading();

        $('.zoom').zoom({ on: 'click' });

        $('.carousel-inner .item:nth-child(1)').addClass('active');
    </script>
}